$(function (){
    var editor = new window.wangEditor('#editor');
    editor.config.uploadImgServer = '/upload/image';
    editor.config.uploadFileName ='image';
    editor.create();

    //提交按钮单击事件
    $('#submit-btn').click( function (event) {
        event.preventDefault();
        var title = $('input[name="title"]').val();
        var content = editor.txt.html();
        var board_id = $('select[name="board_id"]').val();

        zlajax.post({
            'url': '/post/public',
            'data': {title, content, board_id}
        }).done(function (data) {
            setTimeout(function () {
                window.location = '/';
            },2000);
        }).fail(function (error) {
            alert(error.message);
        });
    });
});